package com.intellagric.controller.portal.traceability;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.TraceProduceCategory;
import com.intellagric.service.traceability.trace_produce.ProduceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/11/3
 * @DESC： 溯源模块农产品分类分类信息管理
 */
@Controller
public class ProduceCategoryController {

    @Autowired
    private ProduceCategoryService produceCategoryService;

    /**
     * 查询农产品分类信息
     * @return TraceProduce
     */
    @RequestMapping("/produce/category/{id}")
    @ResponseBody
    public TraceProduceCategory get(@PathVariable String id) {
        return produceCategoryService.getProduceCategoryById(id);
    }

    /**
     * 查询农产品分类信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/category/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return produceCategoryService.getProduceCategoryList();
    }


    /**
     * 查询农产品分类信息列表,并生成树形数据
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/category/tree")
    @ResponseBody
    public LayuiDataGridResult getTree() {
        return produceCategoryService.getProduceCategoryTree();
    }

    /**
     * 查询农产品分类信息列表,并生成树形数据
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/category/tree/select")
    @ResponseBody
    public List<TraceProduceCategory> getTreeSelect() {
        return produceCategoryService.getProduceCategoryTree().getData();
    }
}
